import request from '@/utils/request';

// 新增角色信息;
export async function addRoleInfo(data) {
  return request('/role/addRoleInfo', {
    method: 'POST',
    data,
  });
}

// 修改角色信息;
export async function updateRole(data) {
  return request('/role/updateRole', {
    method: 'POST',
    data,
  });
}

// 基本信息选择部门下拉框接口;
export async function findDepartmentDropdownBox(params) {
  return request('/role/findDepartmentDropdownBox', {
    params,
  });
}

// 根据部门ID查询所有员工;
export async function findUserByDepartmentId(params) {
  return request('/role/findUserByDepartmentId', {
    params,
  });
}

// 功能权限展示;
export async function getFunctional(params) {
  return request('/role/getFunctional', {
    params,
  });
}

// 根据roleID查询功能权限树结构;
export async function getResourceByRoleID(params) {
  return request('/role/getResourceByRoleID', {
    params,
  });
}

// 角色列表查询;
export async function getRoleList(params) {
  return request('/role/getRoleList', {
    method: 'POST',
    params,
  });
}

// 根据roleID获取用户信息树结构;
export async function getUserByRoleID(params) {
  return request('/role/getUserByRoleID', {
    params,
  });
}

// 角色停用启用;
export async function isDisabled({ roleId }) {
  return request(`/role/isDisabled/${roleId}`);
}

// 角色删除;
export async function deleteRole({ roleId }) {
  return request('/role/deleteRole', {
    method: 'DELETE',
    data: roleId,
  });
}

export async function getDepartmentTreeByRole(params) {
  return request('/user/getDepartmentTreeByRole', {
    params,
  });
}

export async function findResourcesByRoleId(params) {
  return request('/resource/findResourcesByRoleId', {
    params,
  });
}

export async function findUserByRoleId(params) {
  return request('/role/findUserByRoleId', {
    params,
  });
}

export async function bindRoleUsers(data) {
  return request('/role/bindRoleUsers', {
    method: 'POST',
    data,
  });
}

export async function updateRoleResources(data) {
  return request('/resource/updateRoleResources', {
    method: 'POST',
    data,
  });
}

//右侧已选角色列表
export async function aoSelectedRoleList(params) {
  return request('/ao/common/getPermission', {
    params,
  });
}

//配置保存角色数据权限
export async function setingPermission(data) {
  return request('/ao/common/setingPermission', {
    method: 'POST',
    data,
  });
}

